Conversation
|
BTW also includes can be simplified to |
|
@SChernykh please review |
| randomx_cache *cache = nullptr; | ||
| auto impl = randomx::selectArgonImpl(flags); | ||
| if (impl == nullptr) { | ||
| return cache; |
There was a problem hiding this comment.
It's probably a bad idea to return uninitialized cache here even if impl can't be nullptr with current code. It should output some error and abort, or throw an exception.
There was a problem hiding this comment.
implcan be NULL if the caller selects an unsupported implementation (e.g. AVX2 on ARM).- It's not returning an uninitialized cache but simply a NULL pointer. It's up to the caller to check for NULLs.
- This is a C-language API, so we can't throw exceptions unless we handle them internally.
There was a problem hiding this comment.
Then it's ok, I somehow thought cache was already allocated at this point.
| randomx_flags randomx_get_flags() { | ||
| randomx_flags flags = RANDOMX_HAVE_COMPILER ? RANDOMX_FLAG_JIT : RANDOMX_FLAG_DEFAULT; | ||
| randomx::Cpu cpu; | ||
| if (HAVE_AES && cpu.hasAes()) { |
There was a problem hiding this comment.
It's better to wrap it into #if HAVE_AES == 1 ... #endif, no need to make it compile-time when preprocessor can handle it.
There was a problem hiding this comment.
If HAVE_AES == 0, it will be optimized out during compilation. I find the code more readable this way.
Can autodetect AES, SSSE3 and AVX2 and sets the JIT flag if supported.
Usage:
AES detection on ARM64 needs testing.